package me.zixing.java.test;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by bingh on 2017/11/1.
 */
public class PhoneNumInfo {
    private String userName;
    private long phoneNum;
    private double remainingSum;

    public PhoneNumInfo(String userName, long phoneNum, double remainingSum) {
        this.userName = userName;
        this.phoneNum = phoneNum;
        this.remainingSum = remainingSum;
    }

    public void showPhoneInfo() {
        System.out.println("用户名:" + this.userName + "\n"
                + "电话号码:" + this.phoneNum + "\n"
                + "余额:" + this.remainingSum
        );
    }


    public static void main(String[] args){
        PhoneNumInfo pn1 =
                new PhoneNumInfo("李想",6879364,11.11);
        PhoneNumInfo pn2 =
                new PhoneNumInfo("刘浩",6879365,22.22);
        PhoneNumInfo pn3 =
                new PhoneNumInfo("巩亿泽",6879366,33.33);
        List<PhoneNumInfo> phoneNumInfos = new ArrayList<>();

        //将3个PhoneNumInfo放入phoneNumInfos
        phoneNumInfos.add(pn1);
        phoneNumInfos.add(pn2);
        phoneNumInfos.add(pn3);

        //遍历
        for (PhoneNumInfo phoneNumInfo:phoneNumInfos) {
            phoneNumInfo.showPhoneInfo();
        }
    }
}
